<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <title></title>
    <meta name="applicable-device" content="pc">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="keywords" content="">
    <meta name="description" content="">
    <link rel="icon" href="/icon.png" />
    <link rel="stylesheet" href="/static/index/css/reset.css">
    <link rel="stylesheet" href="/static/index/lib/bootstrap.css">
    <link rel="stylesheet" href="/static/index/css/common.css">
    <link rel="stylesheet" href="/static/index/css/home.css">
    <link rel="stylesheet" href="/static/index/css/users.css">
    <link rel="stylesheet" href="/static/index/css/page.css">
    <script src="/static/index/lib/jquery-2.1.4.js"></script>
    <script src="/static/index/lib/bootstrap.min.js"></script>
    <script src="/static/index/lib/page.js"></script>
    <script type="text/javascript" src="/static/index/lib/template.js"></script>
    <style type="text/css">
        .pageTest{ height: 50px; margin-top: 50px;    }
        .activP{
          background-color: #367fa9!important;
          color: #fff!important;
        }
        .pick-show{border: none;}
    </style>
    <script>
            var _hmt = _hmt || [];
            (function() {
              var hm = document.createElement("script");
              hm.src = "https://hm.baidu.com/hm.js?8b340ebdd740974de9d621b14ab09b43";
              var s = document.getElementsByTagName("script")[0]; 
              s.parentNode.insertBefore(hm, s);
            })();
        </script>
</head>

<body>
    {include file="public/push"}
    {include file="public/usersHeader"}
    <div class="widthFullScreen">
        <div class="wdSafe user_body clearfix">
            {include file="public/usersLeftNav"}
            <!-- left over -->
            <div class="pull-right right_wrap">
                <div class="nav_common border-top">
                    <ol class="breadcrumb pull-left">
                        <li><a href="/users/index">用户中心</a></li>
                        <li><a href="/users/index">我的订单</a></li>
                        <li class="active">全部订单</li>
                    </ol>
                </div>
                <div class="comUser_wrap">
                    <div class="row main_bkbg pdWrap">
                        <div class="col-md-3 col-sm-3">资质类别</div>
                        <div class="col-md-2 col-sm-2">电话</div>
                        <div class="col-md-1 col-sm-1">地区</div>
                        <div class="col-md-2 col-sm-2">下单时间</div>
                        <div class="col-md-2 col-sm-2">状态</div>
                        <div class="col-md-2 col-sm-2">操作</div>
                    </div>
                    
                    <div id="inforHtml"></div>
                    
                    <!-- 分页 -->
                    <div class="pageTest"></div>
                </div>
            </div>
            <!-- right over -->
        </div>
    </div>
    <div class="widthFullScreen heightGray"></div>

    {include file="public/footer"}

    <!-- dailog -->
    <div class="modal fade modleDailog" tabindex="-1" role="dialog" aria-labelledby="mySmallModalLabel">
        <div class="modal-dialog modal-sm" role="document" style="width: 400px;">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                    <h4 class="modal-title" id="myModalLabel">提示</h4>
                </div>
                <div class="modal-body">
                    <input type="hidden" name="dateId" id="dateId" value="" />
                    <p class="dailog_word">是否确定要消耗一个订单券查看该笔订单？</p>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                    <div type="button" class="btn btn-primary" onclick="checkOrder()">确认</div>
                </div>
            </div>
        </div>
    </div>
    <script type="text/javascript" src="/static/index/layer/layer.js"></script>

    <script type="text/javascript">
    var baseUrl = 'https://api.qikuai100.com/',
        uid = localStorage.getItem("uid"),
        page = 1,
        totalPageNum = 1;

    $(function() {
        $('.modleDailog').modal("hide");
        initOrder();
    });
    /**
     * 初始化数据
     */
    function initOrder() {
        console.log(uid)
        $.ajax({
            type: "POST",
            url: baseUrl + "api/order/list",
            data: {
                uid: uid,
                page: page
            },
            success: function(result) {
                if (result.ret == 0) {
                    var dt = result.data;
                    console.log(dt)
                    if (dt.list.length == 0 || !dt.list.length) {
                        layer.msg("没有最新派单！");
                    }
                    totalPageNum = dt.page_num;
                    var html = '';
                    for(var i = 0; i < dt.list.length; i++){
                        if(dt.list[i].status == '已查看'){
                            html += '<div class="btm_outWrap">'
                                 +      '<div class="row sub_row_box">'
                                 +           '<div class="col-md-3 col-sm-3">'+ dt.list[i].category_name +'</div>'
                                 +           '<div class="col-md-2 col-sm-2">'+ dt.list[i].phone +'</div>'
                                 +           '<div class="col-md-1 col-sm-1">'+ dt.list[i].address +'</div>'
                                 +           '<div class="col-md-2 col-sm-2">'+ dt.list[i].create_time +'</div>'
                                 +           '<div class="col-md-2 col-sm-2">'+ dt.list[i].status +'</div>'
                                 +           '<div class="col-md-2 col-sm-2">'
                                 +               '<a href="/users/usersOrderDt/'+ dt.list[i].id +'" class="btn btn-primary btn-sm" onclick="values('+ dt.list[i].id +')">立即查看</a>'                                                
                                 +           '</div>'
                                 +       '</div>'
                                 +   '</div>';
                        }else{
                            html += '<div class="btm_outWrap">'
                                 +      '<div class="row sub_row_box">'
                                 +           '<div class="col-md-3 col-sm-3">'+ dt.list[i].category_name +'</div>'
                                 +           '<div class="col-md-2 col-sm-2">'+ dt.list[i].phone +'</div>'
                                 +           '<div class="col-md-1 col-sm-1">'+ dt.list[i].address +'</div>'
                                 +           '<div class="col-md-2 col-sm-2">'+ dt.list[i].create_time +'</div>'
                                 +           '<div class="col-md-2 col-sm-2">'+ dt.list[i].status +'</div>'
                                 +           '<div class="col-md-2 col-sm-2">'
                                 +               '<div class="btn btn-primary btn-sm " data-toggle="modal" data-target=".modleDailog" onclick="values('+ dt.list[i].id +')">立即查看</div>'                                                
                                 +           '</div>'
                                 +       '</div>'
                                 +   '</div>';
                        }
                    }

                    document.getElementById('inforHtml').innerHTML = html;

                } else if(result.ret == -1){
                    layer.msg(result.res_info);
                    setTimeout(function(){
                        window.location.href = '/users/companyAutonym';
                    }, 1000);
                } else {
                    layer.msg(result.res_info);
                }
            }
        });
    };

    /**
     * 产看详情 *
     */
    function checkOrder(){
        var id = $('#dateId').val();
        window.location.href = '/users/usersOrderDt/'+ id;
    }

    /**
     *分页组件 *
     */
    $('.pageTest').page({
        leng: totalPageNum,//分页总数
        activeClass: 'activP' , //active 类样式定义
        clickBack:function(page){
            console.log(page);
            page = page;
            initOrder();
        }
    });

    function values(ID) {
        $('#dateId').val(ID);
    }
    </script>
</body>

</html>